<template>
  <div id="upImg">
    <el-upload action="#" :limit="limit" list-type="picture-card" :auto-upload="false" :disabled="isXQ">
      <i slot="default" class="el-icon-plus" />
      <div slot="file" slot-scope="{ file }">
        <img class="el-upload-list__item-thumbnail" :src="file.url" alt="">
        <span class="el-upload-list__item-actions">
          <span
            class="el-upload-list__item-preview"
            @click="handlePictureCardPreview(file)"
          >
            <i class="el-icon-zoom-in" />
          </span>
          <span
            v-if="!disabled"
            class="el-upload-list__item-delete"
            @click="handleDownload(file)"
          >
            <i class="el-icon-download" />
          </span>
          <span
            v-if="!disabled"
            class="el-upload-list__item-delete"
            @click="handleRemove(file)"
          >
            <i class="el-icon-delete" />
          </span>
        </span>
      </div>
    </el-upload>
    <el-dialog :visible.sync="dialogVisible">
      <img width="100%" :src="dialogImageUrl" alt="">
    </el-dialog>

  </div>
</template>

<script>
import { mapGetters } from 'vuex'
export default {
  props: {
    limit: {
      type: Number,
      default() {
        return 1
      }
    }
  },
  data() {
    return {
      dialogImageUrl: '',
      dialogVisible: false,
      disabled: false
    }
  },
  computed: {
    ...mapGetters(['isXQ'])
  },
  methods: {
    handleRemove(file) {

    },
    handlePictureCardPreview(file) {
      this.dialogImageUrl = file.url
      this.dialogVisible = true
    },
    handleDownload(file) {
      console.log(file)
    }
  }
}
</script>

<style scoped>
#upImg /deep/ .el-upload.el-upload--picture-card{
 width: 100px;
 height: 100px;
}
#upImg /deep/ .el-upload.el-upload--picture-card i{
transform: translateY(-50%);
}
#upImg /deep/ .el-upload-list__item.is-ready {
 width: 100px;
 height: 100px;
}
</style>
